package com.xm.zcf.action.index;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.xm.zcf.domain.category.Category;
import com.xm.zcf.domain.product.Product;
import com.xm.zcf.service.category.CategoryService;
import com.xm.zcf.service.product.ProductService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/3/27.
 */
@Controller
@Scope("prototype")
public class IndexAction extends ActionSupport{
    @Resource
    private CategoryService categoryService;
    @Resource
    private ProductService productService;
    public String execute(){
        List<Category>clist= categoryService.findAll();
        ActionContext.getContext().getSession().put("clist",clist);
        List<Product> hlist=productService.findHotProduct(10);
        ActionContext.getContext().put("hlist",hlist);
        List<Product> nlist=productService.findNewProducts(10);
        ActionContext.getContext().put("nlist",nlist);
        return "index";
    }
}
